/**
 * 项目名称: Topic_110.cpp
 * 项目路径: study/DataStructure/LeetCode/树/简单
 * 编辑时间: 2024年08月07日09时28分21秒
 * 用   户: 轻尘
 */

#include <bits/stdc++.h>

using namespace std;

struct TreeNode {
    int val;
    TreeNode *left;
    TreeNode *right;

    TreeNode() : val(0), left(nullptr), right(nullptr) {}

    TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}

    TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
};

class Solution {
public:
    bool flag = true;

    int maxDepth(TreeNode *root) {
        if (!root)return 0;
        return max(maxDepth(root->left), maxDepth(root->right)) + 1;
    }

    bool Order(TreeNode *root) {
        if (!root)return true;
        int l_s = 0;
        if (root->left)l_s = maxDepth(root->left);
        int r_s = 0;
        if (root->right)r_s = maxDepth(root->right);
        cout << l_s << " " << r_s << endl;
        if (abs(l_s - r_s) <= 1) {
            Order(root->left);
            Order(root->right);
        } else {
            flag = false;
            return false;
        }
        return true;
    }

    bool isBalanced(TreeNode *root) {
        Order(root);
        return flag;
    }
};

int main() {

    return 0;
}
